﻿using System;
using Core.Library;
using DataObject.Members;
using DataObject.News;
using DataObject.QA;
using DataObject.Ref;

namespace Event
{
    public partial class Default2 : System.Web.UI.Page
    {
        #region variables, constants, properties
        private int _topHighlightHome = 3;
        private int _topMemberHighlight = 50;
        private int _topQAHome = 3;
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            MetaKeyword.AddMetaTag(Page, Const.Meta_Title, Const.Meta_Sapo);
            MetaKeyword.AddFacebookMetaTag(Page, Const.Meta_Title, Const.Meta_Sapo, Const.SITE_URL, Const.Meta_Image);

            #region banner home
            var banner = RefCache.Ref_GetBannerHome();
            ltrBanner.Text = string.IsNullOrWhiteSpace(banner)
                                 ? @"<img src=""Images/img6.jpg"" style=""display: inline-block; width: 460px; height: 613px;"" />"
                                 : string.Format(
                                     @"<img src=""{0}"" style=""display: inline-block; width: 460px; height: 613px;"" />",
                                     banner);
            #endregion

            #region member highlight
            if (RefCache.Ref_GetStartContestStatus())
            {
                var dt = MembersCache.Member_HighlightHomePage(_topMemberHighlight, RefCache.Ref_GetCurrentRound());
                if (dt != null && dt.Rows.Count >= 4)
                    this.ctrMembersHighlight.Visible = this.ctrMembersHighlight.DataBind(dt);
            }
            #endregion

            #region tin nổi bật trang chủ

            {
                var dt = NewsCache.News_GetHighlightHomepage(
                    top: _topHighlightHome);
                this.ctrNewsHighlight.Visible = this.ctrNewsHighlight.DataBind(dt);
            }
            #endregion

            #region QA nổi bật trang chủ

            {
                var dt = QACache.QA_GetQAHomepage(
                    top: _topQAHome);
                this.ctrQAHomePage.Visible = this.ctrQAHomePage.DataBind(dt);
            }
            #endregion

            #region Quang cao flash
            {
                ltrAdvLeft.Text = Utils.BuildFlash("advLeft", "/images/banner-bottom-340x120.swf", string.Empty, 340, 120);
            }
            #endregion
        }
    }
}